<template>
  <div 
    class="info-item" 
    :class="{ 
      'is-highlighted': highlighted,
      [`type-${type}`]: type
    }"
  >
    <div class="item-header">
      <span class="item-icon">{{ icon }}</span>
      <span class="item-label">{{ label }}</span>
    </div>
    <div class="item-value" :title="String(value)">
      <span v-if="type === 'param' && highlighted" class="param-indicator">→</span>
      {{ formattedValue }}
    </div>
  </div>
</template>

<script setup lang="ts">
import { computed } from 'vue'

interface Props {
  label: string
  value: string | number
  icon: string
  type?: 'path' | 'level' | 'param' | 'type'
  highlighted?: boolean
}

const props = withDefaults(defineProps<Props>(), {
  type: 'path',
  highlighted: false
})

const formattedValue = computed(() => {
  const val = props.value
  
  // 如果值太长，进行截断处理
  if (typeof val === 'string' && val.length > 50) {
    return val.substring(0, 47) + '...'
  }
  
  return String(val)
})
</script>

<style scoped>
.info-item {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.info-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: #cbd5e1;
  transition: background-color 0.2s ease;
}

.info-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.info-item.is-highlighted {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-color: #f59e0b;
}

.info-item.is-highlighted::before {
  background: #f59e0b;
}

.info-item.type-param::before {
  background: #3b82f6;
}

.info-item.type-level::before {
  background: #10b981;
}

.info-item.type-type::before {
  background: #8b5cf6;
}

.item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.item-icon {
  font-size: 1.1rem;
  opacity: 0.8;
}

.item-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #4b5563;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.item-value {
  font-size: 0.95rem;
  font-weight: 500;
  color: #1f2937;
  display: flex;
  align-items: center;
  gap: 6px;
  word-break: break-word;
  line-height: 1.4;
}

.is-highlighted .item-value {
  color: #92400e;
  font-weight: 600;
}

.param-indicator {
  color: #f59e0b;
  font-weight: 700;
  font-size: 1.1rem;
}

/* 特定类型的样式 */
.type-param .item-value {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  background: #f3f4f6;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.9rem;
}

.type-level .item-value {
  color: #059669;
  font-weight: 600;
}

.type-type .item-value {
  color: #7c3aed;
  font-style: italic;
}

/* 响应式设计 */
@media (max-width: 480px) {
  .info-item {
    padding: 12px;
  }
  
  .item-label {
    font-size: 0.8rem;
  }
  
  .item-value {
    font-size: 0.9rem;
  }
}
</style>
